// 统一接口文档， 统一管理请求接口
// 引入qs文件包
import qs from "qs";

// 引入接口路径
import request from "@/request/request";

// 导出==es6导出方式之一
// 精品推荐请求接口
export const recommend = () => request.get("/products/recommend");
// 热门兑换
export const HotAPI = () => request.get("/products/hot");

// 获取验证登录码
// 请求参数在后台存储形式为序列化,进行转化qs.stringify
export const SMSCodeAPI = (params) =>
  request.post("/sendSMS", qs.stringify(params));

// 手机号登录请求
export const PhoneLoginAPI = (params) =>
  request.post("/phoneRegin", qs.stringify(params));

// 微信扫码接口
export const WxLoginAPI = (params) =>
  request.post("/wechatUsers/PCLogin", qs.stringify(params));
// 手机绑定微信
export const BindPhoneAPI = (params) =>
  request.post("/wechatUsers/PCLogin", qs.stringify(params));

// 获取用户信息
export const userProfilesAPI = () => request.get("/shop/userProfiles");

// 详情也面接口
export const GoodsDetailsAPI = (id) => request.get(`/products/${id}`);

// 获取全部商品列表接口  /products
export const allGoodsAPI = (params) => request.get("/products", { params }); // {params:params }

// 加入购物车数据接口
export const addToCartAPI = (params) =>
  request.post("/shop/carts/add", qs.stringify(params));

// 获取购物车数据
export const getCartDataAPI = () => request.get("/shop/carts"); 
// 删除购物车数据
export const delProdAPI = (id) => request.delete(`/shop/carts?productIds=${id}`);
